package edu.cicese.ans;

import com.jsurf.InterestPoint;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.List;

public class Tag implements Serializable {
	private static final long serialVersionUID = 1;
	public List<InterestPoint> points;
	
	public Tag(List<InterestPoint> points) {
		this.points = points;
	}
	
	//! Saves a tag to a .tag file
	public static void saveTagToFile(Tag tag, String filename) {
		try {
			ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream(new File(filename)));
			stream.writeObject(tag);
			stream.close();
		}
		catch (IOException e) { e.printStackTrace(); }
	}
	
	//! Loads a tag from a file
	public static Tag loadTagFromFile(String filename) {
		try {
			ObjectInputStream str = new ObjectInputStream(new FileInputStream(new File(filename)));
			Tag tag = (Tag)str.readObject();
			return tag;
		}
		catch (Exception e) { e.printStackTrace(); }
		return null;
	}
}
